<template>
  <div class="container">
    <!-- 查询条件 -->
    <el-card class="search-box" shadow="hover" style="margin-bottom: 20px;">
      <el-form :model="par" inline class="demo-form-inline">
        <el-form-item label="审批状态：" label-width="100px">
          <el-select v-model="par.AppStatus" placeholder="请选择" clearable style="width: 200px;">
            <el-option v-for="item in ApproveStatusData" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>

        <el-form-item label="姓名：" label-width="60px">
          <el-input v-model="par.NickName" placeholder="请输入姓名" clearable style="width: 200px;" />
        </el-form-item>

        <el-form-item label="请假时间：" label-width="80px">
          <el-date-picker v-model="timeRange" type="daterange" range-separator="至" start-placeholder="开始日期"
            end-placeholder="结束日期" value-format="YYYY-MM-DD" @change="handleDateChange" style="width: 350px;">
          </el-date-picker>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="handleSearch" class="search-btn">查询</el-button>
          <el-button @click="handleReset" class="reset-btn">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <el-table :data="tableData" border stripe :row-hover-effect="true" style="width: 100%; margin-bottom: 20px;">
      <el-table-column prop="nickName" label="姓名" align="center" width="130" />
      <el-table-column prop="depId" label="部门" align="center" width="100">
        <template v-slot="scoped">
          <span> {{depVule[0].children.find((x: any) => x.value == scoped.row.depId)?.label}} </span>
        </template>
      </el-table-column>
      <el-table-column prop="appStatus" label="审批状态" align="center">
        <template v-slot="scoped">
          {{ApproveStatusData.find((x: any) => x.value == scoped.row.appStatus)?.label}}
        </template>
      </el-table-column>
      <el-table-column prop="leaveType" label="请假别类" align="center" width="100" />
      <el-table-column prop="leavePeriod" label="请假时间" align="center" width="330" />
      <el-table-column prop="leaveTime" label="总工时(H)" align="center" width="100" />
      <el-table-column prop="leaveEndTime" label="报道时间" align="center" width="160">
        <template v-slot="scoped">
          {{ scoped.row.leaveEndTime ? moment(scoped.row.leaveEndTime).format("yyyy-MM-DD HH:mm:ss") : "空" }}
        </template>
      </el-table-column>
      <el-table-column prop="leaveReason" label="请假事由" align="center" width="130" />
      <el-table-column prop="leaveLeader" label="部门领导" align="center" width="200" />
      <el-table-column prop="createTime" label="创建时间" align="center" width="160">
        <template v-slot="scoped">
          {{ scoped.row.createTime ? moment(scoped.row.createTime).format("yyyy-MM-DD HH:mm:ss") : "空" }}
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" align="center" min-width="155">
        <template v-slot="scoped">
          <el-button link type="warning" size="small" @click="Updates(scoped.row)">修改</el-button>
          <el-button link type="danger" size="small" @click="Del(scoped.row.leaveId)">删除</el-button>
          <el-button link type="primary" size="small" @click="Approves(scoped.row)"
            v-show="store.ccstore.levelRoleId == scoped.row.levelRoleId">审批</el-button>
          <el-button link type="primary" size="small" @click="Approves(scoped.row)"
            v-show="store.ccstore.levelRoleId != scoped.row.levelRoleId || store.ccstore.userId != route.query.userId">查看详细</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div class="pagination-container">
      <el-pagination v-model:current-page="page.TotalIndex" v-model:page-size="page.TotalSize"
        :page-sizes="[1, 5, 10, 15, 20, 25, 30]" background layout="total, sizes, prev, pager, next, jumper"
        :total="page.totalCount" class="custom-pagination" />
    </div>
  </div>
</template>

<script setup lang="ts">
// 保持原有Script部分不变
</script>

<style scoped>
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background-color: #f8f9fa;
}

.search-box {
  background-color: white;
  border-radius: 10px;
  padding: 20px;
}

.demo-form-inline {
  display: flex;
  gap: 20px;
  align-items: center;
}

.demo-form-inline .el-form-item {
  margin-bottom: 0;
}

.search-btn {
  background-color: #409eff;
  color: white;
  padding: 8px 20px;
  border-radius: 5px;
}

.reset-btn {
  background-color: #f5f7fa;
  color: #606266;
  padding: 8px 20px;
  border-radius: 5px;
}

.el-table {
  background-color: white;
  border-radius: 10px;
}

.el-table th {
  background-color: #f8f9fa;
  color: #303133;
  font-weight: 500;
}

.el-table td {
  color: #606266;
}

.pagination-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.custom-pagination .el-pagination {
  --el-pagination-item-active-background-color: #409eff;
  --el-pagination-item-active-color: white;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .demo-form-inline {
    flex-direction: column;
    align-items: flex-start;
  }

  .el-date-editor {
    width: 100% !important;
  }
}
</style>